# -*- coding: utf-8 -*-


#检查上证指数和深证指数的一致性，输出不一致的日期

not_in_sh ='''
select tdate from dune_xdayquote dx
join dune_stockcode ds on ds.id = dx.tstock_id
where code = 'SZ399001' and tdate > 19960101 and tdate not in (select tdate from 
dune_xdayquote dx
join dune_stockcode ds on ds.id = dx.tstock_id
where code = 'SH000001' and tdate > 19960101)
'''
not_in_sz ='''
select tdate from dune_xdayquote dx
join dune_stockcode ds on ds.id = dx.tstock_id
where code = 'SH000001' and tdate > 19960101 and tdate not in (select tdate from 
dune_xdayquote dx
join dune_stockcode ds on ds.id = dx.tstock_id
where code = 'SZ399001' and tdate > 19960101)
'''

def check(conn):
    ''' 返回(上海市场缺失交易日,深圳市场缺失交易日)'''
    cursor = conn.cursor()
    cursor.execute(not_in_sh)
    rows = cursor.fetchall()
    dates1 = [row[0] for row in rows]
    cursor.execute(not_in_sz)
    rows = cursor.fetchall()
    dates2 = [row[0] for row in rows]
    return dates1,dates2


if __name__ == '__main__':
    from django.core.management import setup_environ
    import wolfox.foxit.settings as settings
    setup_environ(settings)
    from django.db import connection
    from pprint import pprint
    pprint(check(connection))


